.masonry {
    column-count: 3;
    column-gap: 40px;
    column-width: 200px;
}

img {
    width: 100%;
    height: auto;
    display: block;
}

.item {
    padding: 2px;
    position: relative;
    counter-increment:count;
}

.item::after {
    position: absolute;
    display: block;
    top:2px;
    left: 2px;
    width: 24px;
    height: 24px;
    text-align: center;
    line-height: 24px;
    background-color: #000;
    color: #fff;
    content: counter(count);
}